package day0714;

import java.util.Arrays;

public class Test1 {
    public static void main(String[] args) {
        //1.定义
        int[]   a={1,5,8,9};
        int[]   b=new int[4];
        int[]   c=new int[]{1,5,8,9};

        //2.存
        a[0]=10;
        b[b.length-1]=3;
        System.out.println(Arrays.toString(a));//Arrays.toString(a): 将元素+连接为String数据
        System.out.println(Arrays.toString(b));


        //3.取元素
        System.out.println(  c[c.length-1]  );

        //4.复制数组
        //System.arraycopy(复制的数组名,  从哪一位开始复制,  粘贴到哪个数组 ,  从哪个位置开始粘贴,  元素个数);
        System.arraycopy(c,3,c,2,1);
        System.out.println(Arrays.toString(c));


        a=Arrays.copyOf(a, a.length+1);//将a数组扩容







        int[]  arr={3,7,4,1};

        for(int  n  : arr){//forEach
            System.out.println(n);
        }



        String[][]  poem={      {"离","离","原","上","草"} ,
                                {"一","岁","一","枯","荣"}    };
        for (int i = 0; i < poem[0].length; i++) {
            for (int j = poem.length-1; j >=0 ; j--) {//获取poem[i]的每一个元素
                System.out.print(poem[j][i]);
            }
            System.out.println();
        }
        /*for (int i = 0; i < poem.length; i++) {
            for (int j = 0; j < poem[0].length ; j++) {//获取poem[i]的每一个元素
                System.out.print(poem[i][j]);
            }
            System.out.println();
        }*/
















    }
}
